package org.edu.modules.message.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.edu.common.api.vo.Result;
import org.edu.common.aspect.annotation.AutoLog;
import org.edu.common.system.base.controller.BaseController;
import org.edu.common.system.query.QueryGenerator;
import org.edu.modules.message.entity.VeMsgConfig;
import org.edu.modules.message.entity.VeMsgNotice;
import org.edu.modules.message.service.IVeMsgConfigService;
import org.edu.modules.message.service.IVeMsgNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;

/**
* @Description: 消息中心配置
* @Author: jeecg-boot
* @Date:   2021-05-10
* @Version: V1.0
*/
@Api(tags="消息中心配置")
@RestController
@RequestMapping("/message/veMsgConfig")
@Slf4j
public class VeMsgConfigController extends BaseController<VeMsgConfig, IVeMsgConfigService> {
   @Autowired
   private IVeMsgConfigService veMsgConfigService;


   /**
    *   添加
    *
    * @param veMsgConfig
    * @return
    */
   @AutoLog(value = "消息中心配置-添加")
   @ApiOperation(value="消息中心配置-添加", notes="消息中心配置-添加")
   @PostMapping(value = "/add")
   public Result<?> add(@RequestBody VeMsgConfig veMsgConfig) {
       veMsgConfigService.save(veMsgConfig);
       return Result.OK("添加成功！");
   }

   /**
    *  编辑
    *
    * @param veMsgConfig
    * @return
    */
   @AutoLog(value = "消息中心配置-编辑")
   @ApiOperation(value="消息中心配置-编辑", notes="消息中心配置-编辑")
   @PutMapping(value = "/edit")
   public Result<?> edit(@RequestBody VeMsgConfig veMsgConfig) {
       veMsgConfigService.updateById(veMsgConfig);
       return Result.OK("编辑成功!");
   }

   /**
    * 通过key查询
    *
    * @param configKey
    * @return
    */
   @AutoLog(value = "消息中心配置-通过key查询")
   @ApiOperation(value="消息中心配置-通过key查询", notes="消息中心配置-通过key查询")
   @GetMapping(value = "/queryByKey")
   public Result<?> queryById(@RequestParam(name="configKey",required=true) String configKey) {
       VeMsgConfig veMsgConfig = veMsgConfigService.getByKey(configKey);
       if(veMsgConfig==null) {
           return Result.error("未找到对应数据");
       }
       return Result.OK(veMsgConfig);
   }


}
